#include <fstream>
#include <string>
#include "EncodeTest.h"

using namespace SystemTool;

static void LogFile(std::string strFilePath, char *pMsg)
{
    std::fstream os(strFilePath,std::ios::app | std::ios::out);
    os << pMsg << "\n";
    os.close();
}

void EncodeTest()
{
    std::string strUtf8 = "发货时间的话";

    // UTF8->GBK
    std::string strGBK = Encoding::UTF8ToGBK(strUtf8);
    LogFile("/Users/tangyingzhong/Desktop/8-G.log", (char *)strGBK.c_str());

    // UTF8->UTF16
    std::wstring strUTF16 = Encoding::UTF8ToUTF16(strUtf8);
    LogFile("/Users/tangyingzhong/Desktop/8-16.log", (char*)strUTF16.c_str());

    // UTF8->UTF32
    std::wstring strUTF32 = Encoding::UTF8ToUTF32(strUtf8);
    LogFile("/Users/tangyingzhong/Desktop/8-32.log", (char*)strUTF32.c_str());



    // GBK->UTF8
    std::string strFinalUTf8 = Encoding::GBKToUTF8(strGBK);
    LogFile("/Users/tangyingzhong/Desktop/G-8.log", (char*)strFinalUTf8.c_str());

    // GBK->UTF16
    std::wstring strFinalUTf16 = Encoding::GBKToUTF16(strGBK);
    LogFile("/Users/tangyingzhong/Desktop/G-16.log", (char*)strFinalUTf16.c_str());

    // GBK->UTF32
    std::wstring strFinalUTf32 = Encoding::GBKToUTF32(strGBK);
    LogFile("/Users/tangyingzhong/Desktop/G-32.log", (char*)strFinalUTf32.c_str());



    // UTF16->UTF8
    std::string strUTF8_P = Encoding::UTF16ToUTF8(strFinalUTf16);
    LogFile("/Users/tangyingzhong/Desktop/16-8.log", (char*)strUTF8_P.c_str());

    // UTF16->GBK
    std::string strGBK_P = Encoding::UTF16ToGBK(strFinalUTf16);
    LogFile("/Users/tangyingzhong/Desktop/16-G.log", (char*)strGBK_P.c_str());

    // UTF16->UTF32
    std::wstring strUTf32_P = Encoding::UTF16ToUTF32(strFinalUTf16);
    LogFile("/Users/tangyingzhong/Desktop/16-32.log", (char*)strUTf32_P.c_str());



    // UTF32->UTF8
    std::string strUTF8_W = Encoding::UTF32ToUTF8(strFinalUTf32);
    LogFile("/Users/tangyingzhong/Desktop/32-8.log", (char*)strUTF8_W.c_str());

    // UTF32->GBK
    std::string strGBK_W = Encoding::UTF32ToGBK(strFinalUTf32);
    LogFile("/Users/tangyingzhong/Desktop/32-G.log", (char*)strGBK_W.c_str());

    // UTF32->UTF16
    std::wstring strUTF16_W = Encoding::UTF32ToUTF16(strFinalUTf32);
    LogFile("/Users/tangyingzhong/Desktop/32-16.log", (char*)strUTF16_W.c_str());

    return;
}
